#include <iostream>
#include <cmath>
using namespace std;
class Point;
class Distance
{
public:
	Distance(){}
	double MemberDistance(const Point a1, const Point a2);
};
class Point
{
public:
	Point(double x,double y):x(x),y(y){}
	friend double ExternalDistance(const Point a1, const Point a2);
	friend class Distance;
	friend double Distance::MemberDistance(const Point a1, const Point a2);
private:
	double x, y;
};
double ExternalDistance(const Point a1, const Point a2)
{
	const double d = pow((a1.x - a2.x), 2) + pow((a1.x - a2.x), 2);
	return sqrt(d);
}
double Distance::MemberDistance(const Point a1, const Point a2)
{
	const double d = pow((a1.x - a2.x), 2) + pow((a1.x - a2.x), 2);
	return sqrt(d);
}
int main()
{
	double x1, y1, x2, y2;
	cout << "Please input the coordinate value of two points(x1, y1, x2, y2): ";
	cin >> x1 >> y1 >> x2 >> y2;
	cout << "The two points you inputted are: (" << x1 << "," << y1 << ") and (" << x2 << "," << y2 << ")" << endl;
	const Point p1(x1, y1), p2(x2, y2);
	cout << "The distance between two points calculated with friend function is: " << ExternalDistance(p1, p2) << endl;

	cout << "Please input the coordinate value of two points(x1, y1, x2, y2): ";
	cin >> x1 >> y1 >> x2 >> y2;
	cout << "The two points you inputted are: (" << x1 << "," << y1 << ") and (" << x2 << "," << y2 << ")" << endl;
	const Point p3(x1, y1), p4(x2, y2);
	Distance d1;
	cout << "The distance between two points calculated with friend member is: " << d1.MemberDistance(p3, p4) << endl;

	cout << "Please input the coordinate value of two points(x1, y1, x2, y2): ";
	cin >> x1 >> y1 >> x2 >> y2;
	cout << "The two points you inputted are: (" << x1 << "," << y1 << ") and (" << x2 << "," << y2 << ")" << endl;
	const Point p5(x1, y1), p6(x2, y2);
	Distance d2;
	cout << "The distance between two points calculated with friend class is: " << d2.MemberDistance(p5, p6) << endl;

}
